package com.ruoyi.websocket.domain;

import com.fasterxml.jackson.annotation.JsonFormat;

import java.util.Date;

/**
 * WebSocket消息实体
 * 
 * @author ruoyi
 */
public class WebSocketMessage {
    
    /** 消息类型: heartbeat | message | notification */
    private String type;
    
    /** 消息数据 */
    private Object data;
    
    /** 时间戳 */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date timestamp;
    
    /** 发送者ID */
    private Long senderId;
    
    /** 发送者名称 */
    private String senderName;
    
    /** 接收者ID */
    private Long receiverId;
    
    /** 接收者名称 */
    private String receiverName;
    
    public WebSocketMessage() {
        this.timestamp = new Date();
    }
    
    public WebSocketMessage(String type, Object data) {
        this.type = type;
        this.data = data;
        this.timestamp = new Date();
    }
    
    public WebSocketMessage(String type, Object data, Long senderId, String senderName, Long receiverId, String receiverName) {
        this.type = type;
        this.data = data;
        this.timestamp = new Date();
        this.senderId = senderId;
        this.senderName = senderName;
        this.receiverId = receiverId;
        this.receiverName = receiverName;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public Date getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(Date timestamp) {
        this.timestamp = timestamp;
    }

    public Long getSenderId() {
        return senderId;
    }

    public void setSenderId(Long senderId) {
        this.senderId = senderId;
    }

    public String getSenderName() {
        return senderName;
    }

    public void setSenderName(String senderName) {
        this.senderName = senderName;
    }

    public Long getReceiverId() {
        return receiverId;
    }

    public void setReceiverId(Long receiverId) {
        this.receiverId = receiverId;
    }

    public String getReceiverName() {
        return receiverName;
    }

    public void setReceiverName(String receiverName) {
        this.receiverName = receiverName;
    }

    @Override
    public String toString() {
        return "WebSocketMessage{" +
                "type='" + type + '\'' +
                ", data=" + data +
                ", timestamp=" + timestamp +
                ", senderId=" + senderId +
                ", senderName='" + senderName + '\'' +
                ", receiverId=" + receiverId +
                ", receiverName='" + receiverName + '\'' +
                '}';
    }
}
